package com.itsm.example.incident.flow.bo;

import com.itsm.example.audit.pojo.state.AuditState;
import com.itsm.example.statemachine.bo.ItsmState;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.SuperBuilder;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@Data
@AllArgsConstructor
public class IncidentState extends ItsmState {
    IncidentState(Integer value, String desc) {
        super.setValue(value);
        super.setName(desc);
    }
    public static IncidentState START = new IncidentState(-1,"开始");
    public static IncidentState NEW = new IncidentState(10,"新建");
    public static IncidentState FIRST_LINE_ASSIGN = new IncidentState(16,"待分派-一线");
//    public static IncidentState SUB_COMPANY_ASSIGN = new IncidentState(21,"待受理-分公司");
//    public static IncidentState DESKTOP_ASSIGN = new IncidentState(22,"待受理-桌面组");
//    public static IncidentState DEVOPS_ASSIGN = new IncidentState(23,"待受理-运维组");
//    public static IncidentState BUSINESS = new IncidentState(31,"寿险业务工单处理中");
//    public static IncidentState CLOUD = new IncidentState(32,"云平台处理中");
//    public static IncidentState SUB_COMPANY = new IncidentState(33,"处理中-分公司");
//    public static IncidentState DESKTOP = new IncidentState(34,"处理中-桌面组");
//    public static IncidentState DEVOPS = new IncidentState(35,"处理中-运维组");
    public static IncidentState FIRST_LINE = new IncidentState(36,"处理中-一线");
    public static IncidentState USER_VALIDATE = new IncidentState(51,"用户验证");
    public static IncidentState PENDING_CALLBACK = new IncidentState(52,"待回访");
    public static IncidentState WAIT = new IncidentState(55,"等待");
    public static IncidentState CLOSE = new IncidentState(60,"已关闭");


    public static final Map<Integer, IncidentState> STATE_MAP = new ConcurrentHashMap<>();
    static {
        STATE_MAP.put(START.getValue(), START);
        STATE_MAP.put(NEW.getValue(), NEW);
        STATE_MAP.put(FIRST_LINE_ASSIGN.getValue(), FIRST_LINE_ASSIGN);
        STATE_MAP.put(FIRST_LINE.getValue(), FIRST_LINE);
        STATE_MAP.put(USER_VALIDATE.getValue(), USER_VALIDATE);
        STATE_MAP.put(PENDING_CALLBACK.getValue(), PENDING_CALLBACK);
        STATE_MAP.put(WAIT.getValue(), WAIT);
        STATE_MAP.put(CLOSE.getValue(), CLOSE);
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        IncidentState s = (IncidentState) o;
        return Objects.equals(getValue(), s.getValue());
    }
    @Override
    public int hashCode() {
        return Objects.hash(getValue());
    }
}
